//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CSimpleMesh9.h>
///	@path	~/src/graphics/dx9/
///	@date	2009/01/10
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/IVertexBuffer.h"
#include "graphics/IVertexLayout.h"
#include "graphics/IMesh.h"

namespace xeres {

	/*! 
		\class	CSimpleMesh9
		\brief
	*/
	class CSimpleMesh9 : public IMesh
	{
	public:

		/// \ctor
		CSimpleMesh9( TopologyType type , RefWeak<IVertexLayout> layout , RefWeak<IVertexBuffer> vertex , RefWeak<IVertexIndex> index );

		/// \dtor
		virtual ~CSimpleMesh9( void );

		DECL_IOBJECT_CLASS( CSimpleMesh9 , IMesh );

	public:

		/// \impl
		virtual bool OnLostDevice( void );

		/// \impl
		virtual bool OnResetDevice( RefWeak<IDevice> device );

		/// \impl
		virtual RefWeak<IVertexLayout> GetLayout( void );

		/// \impl
		virtual void EstablishBuffer( RenderContext& rc );

		/// \impl
		virtual void Draw( RenderContext& rc );

		/// \impl
		virtual void ClearBuffer( RenderContext& rc );

		///	\name Mesh Interface
		//@{

		/// \brief	Get vertex slot count.
		virtual size_t GetSlotCount( void );

		/// \brief	Get vertex data inside mesh.
		virtual RefWeak<IVertexBuffer> GetVertex( size_t slot );
		
		/// \brief	Get vertex index data.
		virtual RefWeak<IVertexIndex> GetIndex( void );

		//@}

	private:

		//@ data

		D3DPRIMITIVETYPE		m_type;
		size_t					m_prim;

		Ref<IVertexLayout>		m_layout;

		// simple vertex data
		Ref<IVertexBuffer> 		m_vertex;

		// index
		Ref<IVertexIndex>		m_index;
	};
	
} // namespace xeres
